//
//  AddFamilyViewController.m
//  WideHelp
//
//  Created by ENERGY on 2018/8/14.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "AddFamilyViewController.h"
#import "AddFamilyTableViewCell.h"
@interface AddFamilyViewController ()<UITableViewDelegate,UITableViewDataSource,UINavigationControllerDelegate>
@property (nonatomic, strong)UITableView * tableView;
@property (nonatomic, strong)UIView * headerView;
@property (nonatomic, strong)NSMutableArray * cellData;
@end

@implementation AddFamilyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"为家人加入计划";
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    [self.view addSubview:self.tableView];
    
}
#pragma mark - init
- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - BOTTOM_HEIGHT - NAVI_HEIGHT) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_tableView registerClass:[AddFamilyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([AddFamilyTableViewCell class])];
        _tableView.backgroundColor = [UIColor whiteColor];
        _tableView.tableHeaderView = self.headerView;
        _tableView.rowHeight = 155/WIDTH_6_SCALE;
    }return _tableView;
}
- (UIView *)headerView{
    if (!_headerView) {
        _headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 148/WIDTH_6_SCALE)];
        _headerView.backgroundColor = [UIColor whiteColor];
    }return _headerView;
}
- (NSMutableArray *)cellData{
    if (!_cellData) {
        _cellData = @[
  @{@"title":@"计划1", @"content":@"内容1", @"age":@"1-8"},
  @{@"title":@"计划2", @"content":@"内容2", @"age":@"1-8"},
  @{@"title":@"计划3", @"content":@"内容3", @"age":@"1-8"},
  @{@"title":@"计划4", @"content":@"内容4", @"age":@"1-8"}].mutableCopy;
    }return _cellData;
}
#pragma mark - tableViewDelegate和tableViewDataSource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    AddFamilyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([AddFamilyTableViewCell class]) forIndexPath:indexPath];
    cell.model = self.cellData[indexPath.row];
    return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.cellData.count;
}
@end
